package Draft;

import java.util.Arrays;

public class arraytest {
    public static void dfs1(int n, int[] nums){
        if(n == 0){
            return;
        }
        //先不要着急打印，先递归下一层，顺序打印
        dfs1(n-1,nums);
        System.out.print(nums[n-1]+" ");
    }
    public static void dfs2(int n, int[] nums){
        if(n==0){
            return;
        }
        //打印完再去下一层，逆序打印
        System.out.print(nums[n-1]+" ");
        dfs2(n-1,nums);
    }

    public static void main(String[] args) {
        int[] nums = new int[10];
        int n = nums.length;
        for(int i = 0 ; i < n; i++)nums[i]=i+1;
        System.out.println(Arrays.toString(nums));
        dfs1(n,nums);
        System.out.println();
        dfs2(n,nums);
    }
}
